# -*- coding: utf-8 -*-
# 先导入后续要使用的包
import time,SendKeys,datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
# 创建一个webDriver的实例，接下来的所有操作都是在该实例上进行，以Chrome实例为例
driver = webdriver.Chrome()
#窗口最大化
driver.maximize_window()
# 访问德科数智系统
driver.get("http://172.16.70.246/login")
driver.implicitly_wait(5)
# 通过元素定位找到对应元素并输入值进行搜索，完成系统登陆
driver.find_element(By.XPATH,"//input[@placeholder='账号名称']").send_keys("20280")
driver.find_element(By.XPATH,"//input[@placeholder='密码']").send_keys("000000")
driver.find_element(By.XPATH,"//span[text()='登录']").click()
#点击“招聘运营中心”菜单模块，点击到“入职管理”页面，点击“新增待入职”
driver.find_element_by_xpath('//span[text()="招聘运营中心"]').click()
driver.find_element_by_xpath('//span[text()="入职管理"]').click()
driver.find_element_by_xpath('//span[text()="新增待入职"]').click()
#新增待入职弹框内编辑信息
driver.find_element_by_xpath("//div[@class='el-upload-dragger']").click()
time.sleep(1)
SendKeys.SendKeys('E:\zhaopin.pdf')
time.sleep(2)
SendKeys.SendKeys('{ENTER}')
SendKeys.SendKeys('{ENTER}')
time.sleep(1)
Action=ActionChains(driver)
import random
a=random.randint(1,100)
list=['婷婷','花花','小红','华','君','丽']
a1=random.random()
a2=random.choice(list)
t=datetime.datetime.now().strftime("%Y%m%d%H%M%S")
b='徐'+str(a2)+t
time.sleep(5)
# Action.click(driver.find_element_by_xpath('//input[@placeholder="请输入待入职员工姓名"]')).send_keys('徐4').perform()
# Action.reset_actions()
driver.find_element_by_xpath('//input[@placeholder="请输入待入职员工姓名"]').click()
driver.find_element_by_xpath('//input[@placeholder="请输入待入职员工姓名"]').send_keys(u'徐4')
element = driver.find_element_by_xpath('//input[@value="女"]')
Action.click(element).perform()
Action.reset_actions()
# Action.click(driver.find_element_by_xpath('//input[@placeholder="请输入电话"]')).send_keys('18823764512').perform()

# Action.click(driver.find_element_by_xpath('//input[@placeholder="请输入邮箱"]')).send_keys('18823764512@139.com').perform()

# driver.find_element_by_xpath('//input[@value="女"]').click()
driver.find_element_by_xpath('//input[@placeholder="请输入电话"]').send_keys('18823764512')
driver.find_element_by_xpath('//input[@placeholder="请输入邮箱"]').send_keys('18823764512@139.com')
driver.find_element_by_xpath('//input[@placeholder="选择日期"]').clear()
time.sleep(1)
today = datetime.date.today()
driver.find_element_by_xpath("//input[@placeholder='选择日期']").send_keys('2023-12-30')

driver.find_element_by_xpath("//input[@placeholder='机构简称']").click()
time.sleep(1.5)
driver.find_element_by_xpath("//div[@x-placement='bottom-start']/div/div/ul/li[2]").click()
driver.find_element_by_xpath("//input[@placeholder='关联机构合同']").click()
driver.find_element_by_xpath("//span[text()='DKSZTX20230705-腾讯服务合作协议']").click()

driver.find_element_by_xpath('//*[@id="right-main-container"]/div[2]/div[4]/div[1]/div/div/section/div/form/div/div[10]/div/div/div/div/input').click()
time.sleep(2)
driver.find_element_by_xpath("//input[@value='1122']/../span").click()
# Action.click(driver.find_element_by_xpath('//span[text()="腾讯-深圳组"]/..')).perform()
# Action.reset_actions()




driver.find_element_by_xpath('//*[@id="right-main-container"]/div[2]/div[4]/div[1]/div/div/section/div/form/div/div[13]/div/div/div/div/input').click()
time.sleep(2)
driver.find_element_by_css_selector("body > div:nth-child(81) > div.el-scrollbar > div.el-select-dropdown__wrap.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > ul > li.el-select-dropdown__item").click()

# //div[@id='mark']/../../../../../../div[6]/div/div/ul/li[1]
driver.find_element_by_xpath('//*[@id="right-main-container"]/div[2]/div[4]/div[1]/div/div/section/div/form/div/div[14]/div/div/div[1]/div/input').click()
time.sleep(3)
driver.find_element_by_css_selector('body > div:nth-child(82) > div.el-scrollbar > div.el-select-dropdown__wrap.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > ul > li.el-select-dropdown__item').click()

driver.find_element_by_xpath('//*[@id="right-main-container"]/div[2]/div[4]/div[1]/div/div/section/div/form/div/div[16]/div/div/div[1]/div/input').send_keys(u'深圳市 / 德科信息有限公司(总公司)')
time.sleep(3)
driver.find_element_by_xpath('//span[text()="深圳市 / 德科信息有限公司(总公司)"]').click()

driver.find_element_by_xpath('//*[@id="right-main-container"]/div[2]/div[4]/div[1]/div/div/section/div/form/div/div[17]/div/div/div/div[1]/input').click()
time.sleep(3)
driver.find_element_by_css_selector('body > div.el-select-dropdown.el-popper > div.el-scrollbar > div.el-select-dropdown__wrap.el-scrollbar__wrap.el-scrollbar__wrap--hidden-default > ul > li.el-select-dropdown__item.recruitment').click()

driver.find_element_by_xpath('//*[@id="right-main-container"]/div[2]/div[4]/div[1]/div/div/section/div/form/div/div[18]/div/div/div/textarea').send_keys(u'资料终于编辑完成了')

driver.find_element_by_xpath("//span[text()='提交']").click()